<?php 
## include required files
/*******************************/
require_once '../model/email.php';
/*******************************/
## Create Objects
/*******************************/
$emailObj 	= new Model_email();

$email_id=base64_decode($_GET['id']);

if( isset($_POST['editemail_btn'] ))	{
	if($_POST['email_subject']!='' && $_POST['email_content']!='')
	{ ## check the php validation
		extract($_POST);
		$emailArray = array();
		$emailArray['type'] = addslashes(ucfirst(trim($email_type)));
		$emailArray['email_subject'] = addslashes(ucfirst(trim($email_subject)));
		$emailArray['from_name'] = addslashes(ucfirst(trim($from_name)));
		$emailArray['from_email'] = addslashes(trim($from_email));
		$emailArray['email_content'] = addslashes(ucfirst(trim($email_content)));
		$emailObj->editEmailById($emailArray, $email_id) ;
		$_SESSION['msg']="<div class='success_msg'><span>Email content updated successfully!</span></div>";
		header('Location: '.SITE_URL.'/admin/home.php?q=email&page='.$_POST['page']);
		exit;
	}## php validation else
	else
	{
		$_SESSION['msg'] = "<div class='error_msg'><span>Please enter email subject and content</span></div>";
	}
}## main if close

// get email values for edit
$emailList 	= $emailObj->getEmailById($email_id);	
$smarty->assign("emailList",$emailList);
## Set active class variable for left menu  (main menu and sub menu)
$smarty->assign('activeclass', 'email');
$smarty->assign('mainmenu', '2');

unset($emailObj);

$smarty->display(TEMPLATEDIR_ADMIN . 'emails/editemail.tpl');
unset($smarty);
?>